Subject: Correct AI-based errors (e.g. mergers) present in Omni-files using the VAST-program.

Step 1. In Ubuntu: Export "EM" (Channel 1) and "Segmentation" (Segmentation) data from OMNI.

(a) In the Ubuntu Files explorer:

        - Create 3 folders, named "EM", "Segmentation" and "Segmentation_corrected" in the "Corrections"

                folder for the given task at: /seungmount/Omni/TracerTasks/        

        - NOTE: These folders have to be made pre-export.

(b) In OMNI: Export "EM" data:

        - Right click "Channel" in the "Inspector"-window (top-left in OMNI) and select "Properties"

        - Select the "Export" button in the new pop-up window and subsequently select the "Export" option.

        - In the "Export as" pop-up window, choose a filename and save the files in the previously created "EM"                 folder [see Step 1(a)].

(c) In OMNI: Export "Segmentation" data:

        - Right click "Segmentation" in the "Inspector"-window (top-left in OMNI) and select "Properties"

        - Select the "Export" button in the new pop-up window and subsequently select the "Export and reroot                         segments button".

        - In the "Export as" pop-up window, choose a filename and save the files in the previously created                         "Segmentation" folder [see Step 1(a)].

NOTE: Exported files are saved as a single stack in .h5 (hdf) format. The VAST program can't read this file type. Therefore, the exported .h5 files need to be transformed into .tiff format (see Step 2).

Step 2. In Ubuntu: Convert exported .h5 "EM" and "Segmentation" files to .tiff single stack using Jingpeng's python script.

(a) If Python and required packages (python-numpy, python-h5y, python-tifffile and python-tk) are not already installed on your workstation:

        - To install python and required packages run the following command in the Ubuntu Terminal:

                sudo apt-get install python-numpy python-h5py python-tifffile python-tk

(b) Do the following step (c) for both the "EM" and "Segmentation" .h5 files.

(c) Run Jingpeng's python script "h52vast.py" [path: /seungmount/Omni/TracerTasks/Scripts/] by double-clicking the icon.

        - This script opens a window in which you should simply select the .h5 file you want to convert to .tiff                         format.

        - It will save the .tiff single stack in the same folder as the selected .h5 file with the same file name.

NOTE: The .h5 files are converted to .tiff format but are still a single stack, which the VAST program can't handle. Therefore, the .tiff single stack files need to be transformed into a sequence of single .tiff images (see Step 3).

Step 3. In Ubuntu: Save the .tiff single image stack as a sequence of single .tiff images using Fiji (= ImageJ).

(a) If Fiji isn't already installed on your workstation:

        - Extract zipped Fiji file [fiji-linux64.tar.gz] from: /seungmount/Omni/TracerTasks/Software_zipped -                         and save on local drive.

        - OR:

        - Get Fiji online: http://fiji.sc/Downloads (choose Linux 64-bit for the tracer's Alienware desktops).

                - Extract downloaded zipped Fiji file and save on a local drive.

(b) Open Fiji (= ImageJ).

(c) Fiji will always first check for updates (just install updates, but if you don't feel like it, don't ;-) ).

(d) Do the following steps (e + f) for both the "EM" and "Segmentation" .tiff single stack files (do this         sequentially, not parallel).

(e) Open the .tiff single stack file in Fiji:

        - Drag&drop the .tiff single stack file onto the Fiji window.

        - OR:

        - In Fiji, choose "File/Open/" and select the .tiff single stack file from the pop-up window.

(f) Save the .tiff single stack file as a sequence of single .tiff images:

        - Select the image stack that you want to save (This step is only necessary in case multiple files are open                 in Fiji).

        - In Fiji, choose "File/Save as/Image Sequence/".

        - In the "Save Image Sequence" pop-up window choose the following options (the default options are                         typically okay):

                - Format = TIFF

                - Name = 'your desired file name'

                        - NOTE: Make sure 'EM' and 'Segmentation' are included for the EM-images and                                         Segmentation-images, respectively.

                - Start At = 0

                - Digits (1-8) = minimally 3.

                        - NOTE: We typically trace volumes that contain 100-1000 slices, therefore we need at                                         least 3 digits following our "Name"-string, and typically we don't need more                                         than 4.

        - Choose the appropriate previously created folder to save your sequence of single .tiff images in the                         next pop-up window.

                - NOTE: Save the EM-images and Segmentation-images in the "EM" and "Segmentation"                                 folders (see Step 1a), respectively.

NOTE: Your "EM" and "Segmentation" folders should now contain a sequence of .tiff images named e.g. "Daanisthebest_EM_0000", "Daanisthebest_EM_0001", etc. "Daanisthebest_EM_0255". These single images can be imported into the VAST program (see Step 4).

Step 4. In Windows: Open VAST and import EM and Segmentation image sequences.

(a) If VAST isn't already installed on your workstation:

        - Install VAST: Extract zipped VAST file from: /seungmount/Omni/TracerTasks/Software_zipped - and                         save VAST on local drive.

(b) Open VAST

        - NOTE: When VAST is opened for the first time it will ask to install additional files, including a                         manual; just say yes (otherwise this window will pop-up every time you open VAST.

(c) Import EM stack:

        - In VAST, choose "File/Import EM Stack from images/".

        - Select the complete sequence of single .tiff "EM" images to import.

        - Accept all basic options in the pop-up window.

        - This will ask you to save the .vss file: Choose the previously created"EM" folder (see Step 1a) to save                         this .vss file.

        - The EM image stack opens automatically.

(d) Import Segmentation stack:

        - In VAST, choose "File/Import segmentation from images/".

        - Select the complete sequence of single .tiff "Segmentation" images to import.

        - This will ask you to save the .vsseg (= segmentation) file: Choose the previously created                                 "Segmentation_corrected" (see Step 1a) to save this .vsseg file.

        - This opens the "Import segmentation" dialog, in which only the following two options need to be                         adjusted (for all other options the Default is good).

                - To import the "Segmentation" image sequence the Filename string in the "Filename box" is                                 important!

                        - NOTE: The default option will only show the first image of the sequence in the                                         Filename-box, e.g. "Daanisthebest_0000". Selecting this default option will only                                 open this one image!

                        - Use the C++ notation for identifying the sequence: e.g. your image sequence is                                         typically named "Daanisthebest_0000", "Daanisthebest_0001", etc.                                                 "Daanisthebest_0255". To load this image sequence type Daanisthebest_%04d                                         into the filename box (Daanisthebest_%04d reads as: basic string present in all                                         file names to be imported ["Daanisthebest_] followed by 4 digits [%04d].

                                - NOTE: If you've saved the image sequence in Fiji (see Step 3f) choosing only 3                                         digits following your basic file name string the "%04d" notation should                                                 be changed into "I am sure you can figure this out yourself ;-)".

                - To have the "Segmentation"-images aligned with the already imported "EM"-images choose                                 "First slice = 0", "last slice = 255" (in case of 256 slices).

                                - NOTE: When the default option "First slice = 1" is chosen, the                                                         "Segmentation"-images and "EM"-images will be misalligned (just try it                                         if you want to see for yourself).

(e) Correct mistakes in segmentations and export when done:

        - For detailed info on VAST controls check the VAST manual or the VAST protocol in                                         /seungmount/Omni/TracerTasks/Protocols_for_Tracers.

                - NOTE: Previously imported "EM" and "Segmentation" stacks that were saved as .vss and                                 .vsseg files can be opened via the "File/Open EM stack" and "File/Open Segmentation                                 stack" options, respectively.        

        - Save progress regularly, however:

                - Don't constantly overwrite the previous .vsseg file!

                        - Save as a new .vsseg file instead!

                                - This provides you with a recent back-up in case the VAST program messes up                                                 (it shouldn't but it can definitely happen).

        - Export corrected segmentation images:

                - In VAST, choose "File/Export/".

                - Adjust only the following options in the "Export" pop-up window:

                        - Segmentation export as: .tif 24-bit format

                        - Choose the previously created "Segmentation_Corrected" folder to save the exported                                         image sequence.